package com.dnjn.mes.biz.mapper;

import com.dnjn.mes.biz.domain.MesWorkforceShift;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 班次记录 Mapper 接口
 * </p>
 *
 * @author Amber
 * @since 2023-08-29
 */
public interface MesWorkforceShiftMapper extends BaseMapper<MesWorkforceShift> {

    @Update(" UPDATE mes_workforce_shift SET deleted='1' ")
    void updateDeleted();

//    @Select("SELECT workforce_label,`current_date`,IFNULL(TRUNCATE ( capacity / ( SELECT SUM( capacity ) FROM `mes_workforce_shift` WHERE DATE_FORMAT( `current_date`, '%Y-%m-%d' ) BETWEEN '2023-08-01' AND '2023-09-11' ), 2 ),0) AS ratio FROM `mes_workforce_shift` WHERE equipment_id=#{equipmentId} AND workforce_label=#{workforceName} AND DATE_FORMAT(`current_date`,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime} GROUP BY `current_date`")
    @Select("SELECT workforce_label,`current_date`,IFNULL(capacity,0) AS ratio FROM `mes_workforce_shift` WHERE equipment_id=#{equipmentId} AND workforce_label=#{workforceName} AND DATE_FORMAT(`current_date`,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime} GROUP BY `current_date`")
    List<MesWorkforceShift> countWorkforceRecordCapacitys(@Param("startTime") String startTime,@Param("endTime")String endTime,@Param("equipmentId")long equipmentId,@Param("workforceName")String workforceName);

}
